package ar.com.jwa.services;

import java.security.NoSuchAlgorithmException;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

import junit.framework.TestCase;

import ar.com.jwa.commons.architecture.encription.EncryptionServiceImpl;


public class EncryptionServiceTestCase extends TestCase{

	public static void testUsingSecretKey() {
	     try {

	         String secretString = "Gabba Gabba Hey!!";

	         //TODO Guardar la clave en algun lugar seguro 
	         SecretKey desKey = KeyGenerator.getInstance("DES").generateKey();
	         
	         EncryptionServiceImpl desEncrypter = new EncryptionServiceImpl(desKey, desKey.getAlgorithm());
	         
	         // Encrypt the string
	         String desEncrypted = desEncrypter.encrypt(secretString);
	         
	         // Decrypt the string
	         String desDecrypted = desEncrypter.decrypt(desEncrypted);
	         
	         assertTrue(secretString.equals(desDecrypted));

	     } catch (NoSuchAlgorithmException e) {
	     
	     }
	 }
}